Skip to content

simplify staking with Easy* class#51

Draft
mkaczanowski wants to merge 1 commit intomainfrom
simpler_staking
Draft

simplify staking with Easy* class#51
mkaczanowski wants to merge 1 commit intomainfrom
simpler_staking

Conversation

@mkaczanowski
Copy link
Copy Markdown
Contributor

@mkaczanowski mkaczanowski commented Apr 25, 2025

TL;DR

The staker class is overall simple, but thought the integrations with partners we learned it may be beneficial to have a simpler version, especially to start up the gorund work.

What vast majority of people care about is how to stake and unstake tokens, and do it fast. I wanted to have smth that feels like a one liner invocation.

Example

With the alternative approach u can do this:

const signer = LocalSigner(...) // it would be hard and confusing to remove that step imho

const txHash = await new EasyTonPoolStaker({..})
  .buildStakeTx({ amount: '1', validatorAddressPair })
  .sign({ signer, signerAddress })
  .broadcast()
  .exec() // this is to unwrap whole chain
  
console.log('Transaction Hash:', txHash)

The alternative flow is:

const staker = new TonPoolStaker({..})
const unsigedTx = staker.buildStakeTx({ amount: '1', validatorAddressPair })
const signedTx = staker.sign({ signer, signerAddress, tx: unsignedTx })
const hash = staker.broadcast(signedTx)

Alternative flow I can think of:

const txHash = await new TonPoolStaker({..})
  .chain() // <--- new method that creates fluent staker of self
  .buildStakeTx({ amount: '1', validatorAddressPair })
  .sign({ signer, signerAddress })
  .broadcast()
  .exec() // this is to unwrap whole chain

Future improvements

  1. use chorus one validator as default to limit the number of args in buildStakeTx
  2. provide defeult network config
  3. default signer that if not provided accepts the mnemonic (user will see only mnemonic part and won't be even aware there is a "signer abstraction")

@mkaczanowski mkaczanowski marked this pull request as draft April 25, 2025 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant